# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=qt6-quick3d
_qtver=6.1.3
pkgver=${_qtver/-/}
pkgrel=1
arch=(x86_64)
url='https://www.qt.io'
license=(GPL3)
pkgdesc='Qt module and API for defining 3D content in Qt Quick'
depends=(qt6-declarative)
makedepends=(cmake vulkan-headers qt6-shadertools)
# TODO: use system assimp again when a new version is released
optdepends=('qt6-shadertools: for shadergen')
groups=(qt6)
_pkgfn="${pkgname/6-/}-everywhere-src-$_qtver"
source=(https://download.qt.io/official_releases/qt/${pkgver%.*}/$_qtver/submodules/$_pkgfn.tar.xz
        qt6-3d-gcc11.patch)
sha256sums=('91dbdda78204cb27c100ed3a4eed9f3b18466c4349b1f164191a646348410ca6'
            'b056d66a24956755c2aaddc4adddd71f5a945ff9795b0cbf9f43ab4d43b4f8f5')

prepare() {
  patch -d $_pkgfn -p1 < qt6-3d-gcc11.patch # Fix build with GCC 11
}

build() {
  cmake -B build -S $_pkgfn
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt6-base "$pkgdir"/usr/share/licenses/$pkgname
}
